<template>
    <div class="newsinfo-container">
        <h3 class="title">{{newsinfo.content}}</h3>
        <p class="subtitle">
            <span>发表时间：{{newsinfo.date}}</span>
            <span>点击：{{newsinfo.clicktime}}次</span>
        </p>
        <hr>
        <div class="content" v-html="newsinfo.detail"></div>
        <comment-box v-bind:parent-id="1"></comment-box>
    </div>
</template>

<script>
    import {Toast} from 'mint-ui'
    //导入评论组件
    import comment from '../subcomponents/comment.vue'
    export default {
        name: "news-info",
        data(){
            return{
                id:this.$route.params.id,
                newsinfo:[]
            }
        },
        components:{
            'comment-box':comment
        },
        created(){
            this.getNewsInfo()
        },
        methods:{
            getNewsInfo(){
                this.$http.get("http://192.168.1.237:9090/test33/test.php").then(result=>{
                    if(result.body.code==0){
                        result.body.newslist.forEach(item=>{
                            if(item.id==this.id){
                                this.newsinfo=item
                            }
                        })

                    }else {
                        Toast("数据加载失败。。。")
                    }
                })
            }
        }
    }
</script>

<style scoped>
.newsinfo-container{
padding: 0 4px;
}
.newsinfo-container .title{
    font-size: 13px;
    text-align: center;
    margin: 15px 0;
    color: red;
}
.newsinfo-container .subtitle{
    font-size: 13px;
    color: #007aff;
    display: flex;
    justify-content: space-between;
}
.newsinfo-container .content{
    font-size: 13px;
}
</style>